<template>
  <!--  @ok="handleSubmit"-->

  <BasicModal v-bind="$attrs" @register="register" showFooter :title="getTitle" width="70%" :show-ok-btn="false">
    <BasicTable @register="registerTable">
      <template #form-custom> </template>
    </BasicTable>
  </BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, unref } from 'vue';
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicTree, TreeItem } from '@/components/Tree';
import { dknWarehouseList, stockList } from '@/api/heng/stock';
import { BasicTable, useTable, TableAction, FormSchema } from '@/components/Table';
import util from '@/utils/util';
import { useMessage } from '@/hooks/web/useMessage';

const emit = defineEmits(['success', 'register']);
const isUpdate = ref(true);
const { createMessage } = useMessage();


import { columns, searchFormSchema } from './role.data';



const getTitle = ref('');

const searchInfo = ref({});

var tableCfg = {
  title: '',
  api: stockList,
  immediate: false, //是否立即请求接口
  columns: columns,
  formConfig: {
    labelWidth: 120,
    schemas: searchFormSchema,
    autoSubmitOnEnter: true,
  },
  useSearchForm: true,
  showTableSetting: true,
  bordered: true,
  showIndexColumn: false,
};

const [registerTable, { reload, setProps }] = useTable(tableCfg);

const [register, { setModalProps, closeModal }] = useModalInner(async (data, type) => {
  // console.log('--获取数据:', data);
  console.log('--data:', data);
  let title = data.title + "库存";

  getTitle.value = title;
  tableCfg.title = title;

  tableCfg.searchInfo = {
    kuWeiTid: data.kuWeiTid
  };
  searchInfo.value = tableCfg.searchInfo;
  setProps(tableCfg);

  reload();
});
</script>
